package com.zxcl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zxcl.constant.AreaConstant;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zxcl.mapper.AreaMapper;
import com.zxcl.domain.Area;
import com.zxcl.service.AreaService;
/**
 * 描述: []
 * 作者: zxcl
 */
@Service
@CacheConfig(cacheNames = "com.zxcl.service.impl.AreaServiceImpl")
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService{
    @Override
    @Cacheable(key = AreaConstant.AREA_KEY)
    public List<Area> list() {
        return super.list();
    }

    /**
     * 根据父id查询子区域列表
     *
     * @param pid
     * @return
     */
    @Override
    public List<Area> loadAreasByPid(Long pid) {
        return getBaseMapper().selectList(new LambdaQueryWrapper<Area>()
                .eq(Area::getParentId, pid)
        );
    }
}
